
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getCategoryAPI } from '@/apis/layout'

export const useCategoryStore = defineStore('category', () => {
    /* 导航数据列表 */
    const categoryList = ref([])
    const getCategory = async () => {
        /* 获取分类 */
        const { data: res } = await getCategoryAPI()
        /* 对获取到的数据进行校验 */
        if (res.code != 1) new Promise.reject('获取失败')
        categoryList.value = res.result
    }

    return {
        categoryList,
        getCategory,
    }

})
